home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Toolbox
/
Visual Basic Toolbox (P.I.E.)(1996).ISO
/
toolbar
/
databar
/
winfuncs.ba_
/
winfuncs.ba
Wrap
Text File
|
1995-03-16
|
2KB
|
68 lines
'
' Copyright ⌐ 1994-1995, Proficient Solutions Inc.
'
' Project: PSIDataBar Sample Application
' Author : mj
' Date : 15 March 1995
'
' File : WinStuff.Bas
' Purpose: Contains useful Windows utilities
'
'
' Programmer's Notes:
'
'
Option Explicit
' Useful Windows messages
Declare Function SendMessage Lib "User" (ByVal hWnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, lParam As Any) As Long
Declare Function SetWindowLong Lib "User" (ByVal hWnd As Integer, ByVal nIndex As Integer, ByVal dwNewLong As Long) As Long
Declare Function GetWindowLong Lib "User" (ByVal hWnd As Integer, ByVal nIndex As Integer) As Long
Declare Function SetWindowWord Lib "User" (ByVal hWnd As Integer, ByVal nIndex As Integer, ByVal wNewWord As Integer) As Integer
' Things the Window's API really wants (not those weird VB versions)
Global Const WINAPI_TRUE = 1
Global Const WINAPI_FALSE = 0
Global Const WM_USER = &H400
Global Const EM_SETREADONLY = (WM_USER + 31)
'
' Centers window in its parent
'
Sub CenterWindow (Parent As Form, Child As Form)
Dim newTop As Integer
Dim newLeft As Integer
newTop = (Abs(Parent.Height - Child.Height) / 2) + Parent.Top
newLeft = (Abs(Parent.Width - Child.Width) / 2) + Parent.Left
Child.Move newLeft, newTop
End Sub
'
' Changes a TextEdit control to read-only and
' makes the background grey a'la Windows 95
'
Sub SetEditReadOnly (Ctl As Control)
Dim result As Long
result = SendMessage(Ctl.hWnd, EM_SETREADONLY, WINAPI_TRUE, 0&)
' set the back ground to medium gray
Ctl.BackColor = &HC0C0C0
End Sub
'
' Changes a TextBox to white and editable
'
Sub SetEditReadWrite (Ctl As Control)
Dim result As Long
result = SendMessage(Ctl.hWnd, EM_SETREADONLY, WINAPI_FALSE, 0&)
' set the background to white
Ctl.BackColor = &H80000005
End Sub